/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package se.sll.service.catalogue.importer.camel;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.inject.Inject;
import lombok.extern.slf4j.Slf4j;
import org.apache.camel.cdi.CdiCamelContext;

/**
 *
 * @author khaleddaham
 */
@Singleton
@Startup
@Slf4j
public class BootstrapLoadRoutes {

    @Inject private CdiCamelContext camelCtx;

    @PostConstruct
    public void init() throws Exception {
        log.info(">> Create CamelContext and register Camel Route.");

        /**
         * Add property for stax, workaround for ISSUE with Camel
        Properties properties = System.getProperties();
        if ("PROPERTY_NOT_SET".equals(properties.getProperty("org.apache.cxf.stax.allowInsecureParser", "PROPERTY_NOT_SET"))) {
            log.info(">> Setting system property (workaround for ISSUE with Camel): [{} = {}]", new Object[]{"org.apache.cxf.stax.allowInsecureParser", "1"});
            properties.put("org.apache.cxf.stax.allowInsecureParser", "1");
            System.setProperties(properties);
        }
        camelCtx.addRoutes(eiCamelRoute);

        // The route for SMTP notifications from capacity
        camelCtx.addRoutes(smtpCamelRoute);
        camelCtx.start();
        log.info(">> CamelContext created and camel route started.");
         */
  
   }

    @PreDestroy
    public void stop() throws Exception {
        camelCtx.stop();
        log.info(">> CamelContext stopped.");
    }
}
